import {Component, Input, OnInit, ViewChild} from "@angular/core";
import _ from "lodash";
import {Common} from "../../../../providers/common";
import {Content, NavParams} from 'ionic-angular';
import {IrpQjtHomeDetailService} from "./detail.service";

@Component({
  selector: "page-irp-panoramagram-detail",
  templateUrl: "./detail.html",
  providers: [IrpQjtHomeDetailService]
})
export class IrpQjtHomeDetailPage {
  detailDatas = [];
  datas = [];
  index;
  title;

  constructor(private IrpQjtHomeDetailService: IrpQjtHomeDetailService,
              private common: Common,
              private navParams: NavParams) {
    this.datas = this.navParams.get("item");
    this.index = this.navParams.get("index");
    switch (this.index) {
      case 0:
        this.title="最新研究报告";
        this.detailDatas = [{title: "标题", value: ""}, {title: "报告分类", value: ""}, {
          title: "证券名称",
          value: ""
        }, {title: "所属作业", value: ""}, {title: "评级", value: ""}, {title: "作者", value: ""}, {
          title: "得分",
          value: ""
        }, {title: "状态", value: ""}, {title: "撰写时间", value: ""}];
        _.forEach(this.datas, (item, index) => {
          switch (index) {
            case 1:
              this.detailDatas[0].value = item;
              break;
            case 2:
              this.detailDatas[1].value = item;
              break;
            case 4:
              this.detailDatas[7].value = item;
              break;
            case 5:
              this.detailDatas[8].value = item;
              break;
            case 8:
              this.detailDatas[5].value = item;
              break;
            case 10:
              this.detailDatas[4].value = item;
              this.detailDatas[6].value = item;
              break;
            case 11:
              this.detailDatas[2].value = item;
              break;
            default:
              break;
          }
        })
        break;
      case 1:
        this.title="最新股票研究报告排名";
        this.detailDatas = [{title: "股票代码", value: ""}, {title: "股票名称", value: ""}, {title: "报告次数", value: ""}];
        _.forEach(this.datas, (item, index) => {
          switch (index) {
            case 0:
              this.detailDatas[0].value = item;
              break;
            case 1:
              this.detailDatas[1].value = item;
              break;
            case 2:
              this.detailDatas[2].value = item;
              break;
            default:
              break;
          }
        })
        break;
      case 2:
        this.title="最近出差";
        this.detailDatas = [{title: "标题", value: ""}, {title: "申请时间", value: ""}, {
          title: "开始日期",
          value: ""
        }, {title: "结束日期", value: ""}, {title: "报告", value: ""}];
        _.forEach(this.datas, (item, index) => {
          switch (index) {
            case 1:
              this.detailDatas[0].value = item;
              break;
            case 4:
              this.detailDatas[1].value = item;
              break;
            case 5:
              this.detailDatas[2].value = item;
              break;
            case 6:
              this.detailDatas[3].value = item;
              break;
            case 10:
              this.detailDatas[4].value = item;
              break;
            default:
              break;
          }
        })
        break;
      case 3:
        this.title="最近策略推荐";
        this.detailDatas = [{title: "推荐日期", value: ""}, {title: "股票代码", value: ""}, {
          title: "股票名称",
          value: ""
        }, {title: "所属作业", value: ""}, {title: "收盘日期", value: ""}, {title: "股价", value: ""}, {
          title: "总市值（亿）",
          value: ""
        }, {title: "相关报告", value: ""}];
        _.forEach(this.datas, (item, index) => {
          switch (index) {
            case 3:
              this.detailDatas[0].value = item;
              break;
            case 5:
              this.detailDatas[4].value = item;
              break;
            case 6:
              this.detailDatas[1].value = item;
              break;
            case 7:
              this.detailDatas[2].value = item;
              break;
            case 10:
              this.detailDatas[3].value = item;
              break;
            case 11:
              this.detailDatas[5].value = item;
              break;
            case 12:
              this.detailDatas[6].value = item;
              break;
            case 13:
              this.detailDatas[7].value = item;
              break;
            default:
              break;
          }
        });
        break;
      case 4:
        this.title="最近金股推荐";
        this.detailDatas = [{title: "推荐日期", value: ""}, {title: "股票代码", value: ""}, {
          title: "股票名称",
          value: ""
        }, {title: "推荐日五日均价", value: ""}, {title: "计算日期", value: ""}, {title: "计算日五日均价", value: ""}, {
          title: "结束日期",
          value: ""
        }, {title: "结束日五日均价", value: ""},  {title: "收益率", value: ""}, {
          title: "推荐日持仓（万股）",
          value: ""
        }, {title: "当前持仓（万股）", value: ""}];
        _.forEach(this.datas, (item, index) => {
          switch (index) {
            case 2:
              this.detailDatas[1].value = item;
              break;
            case 3:
              this.detailDatas[2].value = item;
              break;
            case 5:
              this.detailDatas[0].value = item;
              break;
            case 6:
              this.detailDatas[4].value = item;
              break;
            case 7:
              this.detailDatas[6].value = item;
              break;
            case 8:
              this.detailDatas[3].value = item;
              break;
            case 9:
              this.detailDatas[7].value = item;
            case 10:
              this.detailDatas[8].value = item;
              break;
            case 11:
              this.detailDatas[9].value = item;
              break;
            case 12:
              this.detailDatas[10].value = item;
              break;
            default:
              break;
          }
        });
        break;
      case 5:
        this.title="最新晨会股票推荐";
        this.detailDatas = [{title: "推荐日期", value: ""}, {title: "股票代码", value: ""}, {
          title: "股票名称",
          value: ""
        }, {title: "评级", value: ""}, {title: "持仓", value: ""}, {title: "历史推荐记录", value: ""}, {
          title: "推荐日至今涨跌幅",
          value: ""
        }, {title: "相关报告", value: ""}];
        _.forEach(this.datas, (item, index) => {
          switch (index) {
            case 1:
              this.detailDatas[1].value = item;
              break;
            case 2:
              this.detailDatas[2].value = item;
              break;
            case 3:
              this.detailDatas[0].value = item;
              break;
            case 4:
              this.detailDatas[3].value = item;
              break;
            case 5:
              this.detailDatas[4].value = item;
              break;
            case 6:
              this.detailDatas[5].value = item;
              break;
            default:
              break;
          }
        });
        break;
      case 6:
        this.title="最新股票池调整";
        this.detailDatas = [{title: "调整日期", value: ""}, {title: "股票代码", value: ""}, {
          title: "股票名称",
          value: ""
        }, {title: "最新评级", value: ""}, {title: "上次评级", value: ""}, {title: "调整方向", value: ""}, {
          title: "股票池",
          value: ""
        }];
        _.forEach(this.datas, (item, index) => {
          switch (index) {
            case 2:
              this.detailDatas[1].value = item;
              break;
            case 3:
              this.detailDatas[2].value = item;
              break;
            case 7:
              this.detailDatas[0].value = item;
              break;
            case 8:
              this.detailDatas[5].value = item;
              break;
            case 11:
              this.detailDatas[6].value = item;
              break;
            default:
              break;
          }
        });
        break;
      default:
        break;
    }
  }

  ionViewDidEnter() {
  }

}
